<?php

class operatorlog_logs {

    public function logSetTagInfo() {
        $data['app'] = $_GET['app'];
        $data['ctl'] = $_GET['ctl'];
        $data['act'] = $_REQUEST['action'] ? $_REQUEST['action'] : $_GET['act'];
        $log_key = $data['app'] . '-' . $data['ctl'] . '-' . $data['act'];
        $register = array(
            'content-admin_article-settag' => array(
                'app' => 'content',
                'ctl' => 'admin_article',
                'act' => 'setTag',
                'module' => 'content',
                'operate_type' => '设置文章标签',
                'template' => '文章ID %s 批量设置文章标签 %s',
                'param' => 'article_id'
            ),
            'image-admin_manage-settag' => array(
                'app' => 'image',
                'ctl' => 'admin_manage',
                'act' => 'setTag',
                'module' => 'image',
                'operate_type' => '设置图片标签',
                'template' => '图片ID %s 批量设置图片标签 %s',
                'param' => 'image_id'
            ),
            'aftersales-admin_returnproduct-settag' => array(
                'app' => 'aftersales',
                'ctl' => 'admin_returnproduct',
                'act' => 'setTag',
                'module' => 'aftersales',
                'operate_type' => '设置售后服务标签',
                'template' => '售后服务单ID %s 批量设置售后服务标签 %s',
                'param' => 'return_id'
            )
        );
        $ids = '';
        $unseria_ids = unserialize($_POST['filter']);
        foreach ($unseria_ids[$register[$log_key]['param']] as $value) {
            $ids .= $value . ',';
        }
        $tagName = '';
        foreach ($_POST['tag']['stat'] as $key => $value) {
            if ($value == '0') {
                $tagName .= $_POST['tag']['name'][$key] . ',';
            }
        }
        
        $obj = new desktop_user();
        $data['username'] = ($obj->get_login_name()) ? ($obj->get_login_name()) : 'system_core';
        
        $data['module'] = $register[$log_key]['module'];
        $data['operate_type'] = $register[$log_key]['operate_type'];
        $data['dateline'] = time();
        $data['memo'] = sprintf($register[$log_key]['template'], $ids, $tagName);
        app::get('operatorlog')->model('normallogs')->insert($data);
    }
}//End Class